//
// Created by PC on 2024/5/24.
//


#include <iostream>
#include "linkedListUtil.h"
using namespace std;

Node * reverse(Node *head)
{
    Node *pre = nullptr;
    Node * cur = head;
    while (head)
    {
        cur=head->next;
        head->next=pre;
        pre=head;
        head=cur;
    }
    return new Node{0,pre};
}

int main()
{
    vector<int> v{1,2,3,4,5};
    Node *h = build(v);
    printLinkedList(h);
    h = reverse(h->next);
    printLinkedList(h);
    return 0;
}